GBML manual / Collision

tile_shape

The shape of the collision square at (x, y): SHAPE_FULL (0) for an ordinary square, or the number of the slope it has (SHAPE_45_FLOOR_UP_RIGHT and the other SHAPE_ names, or a number from 128 up for a shape you drew yourself).

Syntax

tile_shape(x, y) -> int

Arguments

NameType
xreal
yreal

Returns

int

Description

The shape of the collision square at (x, y) in the current room. A collision square is 8 by 8 pixels. Its class (TILE_PASS, TILE_SOLID or TILE_LOW_COVER) says whether it blocks. Its shape says which of its pixels do. Most squares are the full square, SHAPE_FULL, which is the number 0. A square drawn as a slope has a different number: a ramp, a half ramp, a sloped ceiling. The names are SHAPE_45_FLOOR_UP_RIGHT and the others listed on the Slopes page. A shape you drew yourself in the Room Editor has a number from 128 up and no name.

x and y are a place in the room, counted from the room's top-left corner, the same way tile_class counts them. Any point inside the square gives the same answer.

Only the shape comes back. The class and the flags of the same square are what tile_class and tile_flags read, and a shape does not change them. A square whose class is TILE_PASS blocks nothing, so its shape does not matter.

What counts as no shape

Example

if (tile_shape(x, y + 8) != SHAPE_FULL) {
    hsp *= 0.75;
}

Slows the walker down while the square just under it is a slope of any kind.

On the GBA

The shape says which of the square’s 64 pixels are solid, when the square is solid or low cover. A pass square blocks nothing whatever its shape, but its shape still says where its flag bits count. A point outside the room, a room with no collision tile layer and a room with no slopes all read SHAPE_FULL. The class and the flag bits of the same square are tile_class and tile_flags; a shape never changes the class, and tile_flags reads the flag bits only inside the shape.

See also: tile_set_shapetile_ground_ytile_classtile_solidSlopesSHAPE_FULL